/*
 * Copyright (c) 2021.版权所有高金磊
 */

package 领扣算法.A简单题.交替位二进制数;

public class Main {
    public boolean hasAlternatingBits(int n) {
        //110
       int pre=n&1;
       n>>=1;
       while (n>0){
           if (pre==(n&1)){
               return false;
           }
           pre=n&1;
           n>>=1;
       }
       return true;
    }
}
